/*************************************************
Author: Aven 
Date: 2/25/2013
Description:
Notes: 
*************************************************/

#ifndef __CAuctionConfig_h__
#define __CAuctionConfig_h__

#include "CTArray.h"
#include "../maindef.h"
#include "commclass.h"

enum
{
    AUCTION_MONEY_TYPE_GOLD     = 1,
    AUCTION_MONEY_TYPE_SILVER   = 2,
};

enum
{
    AUCTION_REQ_BLIND          = 1,  //暗拍
    AUCTION_REQ_PUBLIC         = 2,  //竞拍
    AUCTION_REQ_RECORD         = 3,  //查询出价历史
    AUCTION_REQ_PUBLIC_INFO    = 4,  //获取竞拍信息
    AUCTION_REQ_BLIND_INFO     = 5,  //获取暗拍信息
    AUCTION_REQ_TODAY_HIS      = 6,  //获取今日拍卖结果
    AUCTION_REQ_YESDAY_HIS     = 7,  //获取昨日拍卖结果
    AUCTION_REQ_MAR            = 8,  //跑马灯

    AUCTION_INNER_BACK_BLIND_MONEY  = 100,  //暗拍退款
};

//竞拍钱币类型
enum
{
    ECONST_AUCTION_HIGHER_GOLD      = 1,    //金币竞拍
    ECONST_AUCTION_HIGHER_SILVER    = 2,    //银币竞拍
    ECONST_AUCTION_LOWER_GOLD       = 3,    //金币暗拍
    ECONST_AUCTION_LOWER_SILVER     = 4,    //银币暗拍
    ECONST_AUCTION_FOCUS_GOLD       = 5,    //金币压轴竞拍
};

class CAuctionGoodsUnit
{
public:
    CAuctionGoodsUnit ()
    {
        _usGoodsId = 0;
        _ucItemType = 0;
        _usItemConfigID = 0;
        _shItemCount = 0;
        _iSilverPrice = 0;
        _iGoldPrice = 0;
    }

    bool HasConfig ()  //合法的配置过返回真.  非法的未假
    {
        return ((0 != _ucItemType && 0 != _shItemCount && 0 != _usItemConfigID));
    }

    unsigned short  _usGoodsId;    //拍卖物品id
    unsigned char   _ucItemType;
    unsigned short  _usItemConfigID;
    short           _shItemCount;
    int _iSilverPrice;         //银币起拍价
    int _iGoldPrice;         //金币起拍价
};

//拍卖品配置
class CAuctionConfigUnit
{
public:
    CAuctionConfigUnit ()
    {
        _usGoodsId = 0;
        _ucZoneOpenDay = 0;
    }

    unsigned short _usGoodsId;      //拍卖商品id

    //仅开服前一周的压轴拍卖商品需要填，1：开服第一天的压轴商品，2：开服第二天的压轴商品，以此类推，N(N<=7)：标识开服第N天的压轴商品.  开服第一周以后的压轴商品默认为0
    unsigned char _ucZoneOpenDay;   
};

//拍卖会配置信息
class CAuctionConfig
{
public:
	CAuctionConfig()
    {
        _astGoods.Clear();
        _astFinal.Clear();
        _astPublic.Clear();
        _astBlind.Clear();
	}

    static bool IsValidGoods (unsigned short usGoodsId)
    {
        if (0 == usGoodsId || usGoodsId > MAX_AUCTION_GOODS_NUM)
        {
            return false;
        }

        return true;
    }

    static bool IsValidAuctionType (unsigned char ucAuction)
    {
        if (ucAuction < AUCTION_TYPE_MIN || ucAuction > AUCTION_TYPE_MAX)
        {
            return false;
        }

        return true;
    }
    
    CAuctionGoodsUnit & GetAuctionGoodsConfig(unsigned short usGoodsId);

    int GenerateAuctionGoods(unsigned char ucAuctionType, CAuctionGoodsUnit & stData);

    
    int AddAuctionConfig (unsigned char _ucAuctionType, CAuctionConfigUnit & stData); 

    int AddAuctionGoodsConfig (CAuctionGoodsUnit & stData);

private:
    CTLib::CTArray<CAuctionGoodsUnit, MAX_AUCTION_GOODS_NUM>          _astGoods;
    CTLib::CTArray<CAuctionConfigUnit, MAX_AUCTION_FINAL_GOODS>       _astFinal;    //压轴拍卖商品配置
    CTLib::CTArray<CAuctionConfigUnit, MAX_AUCTION_PULIC_GOODS>       _astPublic;   //竞拍商品配置
    CTLib::CTArray<CAuctionConfigUnit, MAX_AUCTION_BLIND_GOODS>       _astBlind;    //暗拍商品配置
};

#endif // __CAuctionConfig_h__

